unit ResultView;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, ComCtrls, tasacschart, chartproperties, Menus, apgabstractunit;

type
  TfrmResultView = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    TabSheet2: TTabSheet;
    PopPanel: TPanel;
    MortPanel: TPanel;
    PopupMenu1: TPopupMenu;
    Properties1: TMenuItem;
    procedure FormCreate(Sender: TObject);
    procedure Properties1Click(Sender: TObject);
  private
    { Private declarations }
    m_PopChart, m_MortChart : TAgeYearChart;
  public
    { Public declarations }
    procedure UpdateCharts;
    destructor Destroy; override;
  end;

var
  frmResultView: TfrmResultView;

implementation

{$R *.dfm}


procedure TfrmResultView.UpdateCharts;
begin
    m_PopChart.PaintChart;
    m_MortChart.PaintChart;
end; // TfrmResultView.UpdateCharts


procedure TfrmResultView.FormCreate(Sender: TObject);
begin
    m_PopChart := TAgeYearChart.Create(PopPanel, vPopulation);
    m_MortChart := TAgeYearChart.Create(MortPanel, vMortality);
end;

procedure TfrmResultView.Properties1Click(Sender: TObject);
var
   frmChartProperties : TfrmChartProperties;
   c : TAgeYearChart;
begin
   case (PageControl1.TabIndex) of
      0: c := m_PopChart;
      1: c := m_MortChart;
   end; // case
   frmChartProperties := TfrmChartProperties.Create(Self, c as IChart);
   if mrOK = frmChartProperties.ShowModal then
      c.PaintChart;
end;

destructor TfrmResultView.Destroy;
begin
   m_PopChart.Free;
   m_MortChart.Free;
   inherited;
end; // TfrmResultView.Destroy

end.


